<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>从IE打开Chrome浏览器</title>
    <link rel="stylesheet" href="https://www.unpkg.com/ew-message/dist/ew-message.min.css">
    <style>
        body {
            font-family: "微软雅黑", sans-serif;
            background-color: #f0f0f0;
            color: #333;
            margin: 0;
            padding: 0;
        }

        header {
            background-color: #4CAF50;
            color: white;
            padding: 20px;
            text-align: center;
            font-size: 24px;
        }

        main {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 80vh;
            flex-direction: column;
        }

        .button {
            background-color: #4CAF50;
            color: white;
            font-size: 18px;
            padding: 15px 30px;
            border: none;
            cursor: pointer;
            border-radius: 5px;
            transition: background-color 0.3s ease;
        }

        .button:hover {
            background-color: #45a049;
        }

        .input-field {
            padding: 10px;
            font-size: 16px;
            margin-bottom: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
            width: 300px;
            text-align: center;
        }
    </style>
</head>

<body>
    <header>
        从IE浏览器打开Chrome浏览器
    </header>
    <main>
        <input id="urlInput" class="input-field" type="text" placeholder="请输入URL" />
        <button class="button" onclick="openInChrome()">在Chrome中打开</button>
    </main>

    <script src="https://www.unpkg.com/ew-message/dist/ew-message.min.js"></script>
    <script>
        // 函数：通过ActiveXObject从IE打开Chrome
        function IEToChrome(url) {
            try {
                // 使用ActiveXObject创建WScript.Shell对象
                var shell = new ActiveXObject("WScript.Shell");
                // 运行Chrome并传入URL
                shell.Run('chrome ' + url, 0, true);
            } catch (e) {
                ewMessage.warning("无法在当前浏览器中执行此操作。此功能仅在IE浏览器中支持。");
            }
        }

        // 函数：获取输入的URL并调用IEToChrome
        function openInChrome() {
            var url = document.getElementById('urlInput').value.trim();
            if (url) {
                IEToChrome(url);
            } else {
                ewMessage.warning("请输入有效的URL！");
            }
        }
    </script>
</body>

</html>